function getCookie(name) {
    var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)")
    if (arr = document.cookie.match(reg))
        return decodeURI(arr[2])
    else
        return null
}

function setCookie(name, value, time) {
    time = time || 86400
    var exp = new Date()
    exp.setTime(exp.getTime() + time * 1000)
    document.cookie = name + "=" + encodeURI(value) + ";expires=" + exp.toGMTString()
}

function delCookie(name) {
    var exp = new Date()
    exp.setTime(exp.getTime() - 1)
    var cval = getCookie(name)
    if (cval != null)
        document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString()
}

function getStorage(name) {
    var name = localStorage.getItem(name)
    return name
}

function setStorage(name, value) {
    localStorage.setItem(name, value)
}

function delStorage(name) {
    localStorage.removeItem(name)
}

export default {
    getCookie,
    setCookie,
    delCookie,
    getStorage,
    setStorage,
    delStorage
}
